<style scoped>
  .flex-form{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .flex-form > div{
    min-width: 546px;
    margin-bottom: 16px;
  }

  .flex-form .line{
    height: 20px;
    border-top: 1px solid #cacaca;
    width: 100%;
  }

  .flex-form .title{
    width: 100%;
    padding-left: 16px;
    margin: 0;
  }

</style>
<template>
  <div class="finance-class">
    <el-form ref="form" :model="form" style="margin:0 16px">
        <el-form-item  v-for="(item, index) in container.fcList" :key="index" :label="item.label">
            <el-radio :disabled="readonly" v-if="item.type === 'radiobox'" v-for="(val, key) in item.range" :key="key" v-model="form[item.name]" :label="key">{{val}}</el-radio>
            <el-checkbox :disabled="readonly" v-if="item.type === 'checkbox'" v-for="(val, key) in item.range" :key="key" v-model="form[item.name]" :label="key">{{val}}</el-checkbox>
        </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        container:{},
        form:{}
      }
    },
    created(){
    },
    props:{
      readonly: {
        type: Boolean,
        default: false
      }
    },
    methods: {
      initData(vendorId){
        let _this = this;
        this.axios.post(this.lib.config.host.vendorMgt + '/vendormgt/questionary/survey/toView/' + vendorId).then((res)=>{
          _this.container = res.data.resultMap.container;
          res.data.resultMap.container.fcList.forEach((item)=>{
            _this.$set(_this.form, item.name, item.type === 'checkbox'?item.value.split(','): item.value);
          });
        });
      },
      getData(isCheck){
        let data = {};
        this.container.fcList.forEach((item)=>{
          if (item.type === 'checkbox') {
            data[item.name] = this.form[item.name].toString().replace('[','').replace(']','').trim();
          } else {
            data[item.name] = this.form[item.name];
          }
        });
        return new Promise((resolve, reject)=>{
          resolve({
            data: {
              surveyJsonStr: JSON.stringify(data)
            },
            check: true
          });
        });
      }
    }
  }
</script>
